import java.io.*;//异常报错
import java.net.*;//服务器套接字
public class Sever {
    public static void main(String[] args) throws IOException {
        ServerSocket sv=new ServerSocket(12345);
        while(true){
            Socket sk=sv.accept();//接受一个客户端的连接

            InputStream in=sk.getInputStream(); //得到该连接中的流
            OutputStream out= sk.getOutputStream();

            InputStreamReader ir=new InputStreamReader(in);//将流做大做强
            OutputStreamWriter ow=new OutputStreamWriter(out);
            BufferedReader br=new BufferedReader(ir);
            BufferedWriter bw=new BufferedWriter(ow);

            String s=br.readLine();//接收客户端的名字
            System.out.println(s+"来访");//并打印到屏幕上

            bw.write(s+"你好");//问候客户端
            bw.newLine();
            bw.flush();

            sk.close();
        }
    }
}
